﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace BDSim
{
    public class ConstellationDLL
    {
        /// <summary>
        /// 星座生成动态库
        /// </summary>
        /// <param name="input">星座生成输入参数1</param>
        /// <param name="param">星座生成输入参数2</param>
        /// <param name="output">星座生成输出信息（output.SatPV:星座的卫星位置速度数组(数组大小为param.T);output.OrbitPV:星座轨道信息（输出60*轨道面数颗卫星位置速度信息）</param>
        [DllImport("ConstellationDLL.dll", EntryPoint = "WalkerConstGen", CallingConvention = CallingConvention.Cdecl)]
        static extern void WalkerConstGen(ConstGenInput input, ConstGenParam param, out ConstGenOutput output);

        /// <summary>
        /// 星座生成
        /// </summary>
        /// <param name="seedOrbit">种子卫星位置速度结构体</param>
        /// <param name="T">卫星总数</param>
        /// <param name="P">轨道面个数</param>
        /// <param name="F">相位参数</param>
        /// <param name="result">输出卫星位置速度结构体组(ECI坐标系)</param>
        public static void WalkerConst(NodePosVel seedOrbit, int T, int P, int F, out NodePosVel[] satPV, out NodePosVel[] orbitPV)
        {
            ConstGenInput input = new ConstGenInput() { OrbitPV = seedOrbit };
            ConstGenParam param = new ConstGenParam() { F = F, T = T, P = P };
            ConstGenOutput output;
            WalkerConstGen(input, param, out output);
            satPV = output.SatPV;
            orbitPV = output.OrbitPV;
        }

    }
}
